import UniformScaleBase from "./UniformScaleBase";

const { ccclass, property, requireComponent, menu } = cc._decorator;

/**
 * 等比缩放背景图, 保证背景节点能在当前分辨率下等比铺满
 */
@ccclass
@requireComponent(cc.Sprite)
@menu('UniformScale/UniformScaleBg')
export default class UniformScaleBg extends UniformScaleBase {

    protected doUniformScale() {
        if (!this.active)
            return;
        const sprite = this.getComponent(cc.Sprite);
        if (!sprite || !sprite.spriteFrame)
            return;
        const imgSize = sprite.spriteFrame.getOriginalSize();
        this.scale = this.getScaleMax(imgSize) * this.canvasScale;
    }

}
